#pragma once

#include "rewine/impl/CExport.hpp"

#include <memory>

namespace rewine
{

using dl_handle_t = void *;

class CDsoExport : public CExport {
private:

    std::shared_ptr<dl_handle_t> m_Handle;

private:

    CDsoExport() = default;
    ~CDsoExport() override = default;

public:

    static std::shared_ptr<CDsoExport> create() {
        auto&& p = std::shared_ptr<CDsoExport>(new CDsoExport(), getDeleter());
        return std::move(p);
    }

public:

    void setHandle(const std::shared_ptr<dl_handle_t> &pHandle, void *address) {
        m_Handle = pHandle;
        setValue(address);
    }

public:

    bool isValid() const {
        return m_Handle.operator bool();
    }

};

} // namespace rewine
